﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ArtMath.Window
{
    public partial class ProgressWindow : Form
    {
        public ProgressWindow(string desc, int pbmax, Action<BackgroundWorker> action)
        {
            InitializeComponent();
            label1.Text = desc;
            progressBar1.Maximum = pbmax;
            backgroundWorker1.DoWork += (object sender, DoWorkEventArgs e) =>
              {
                  action?.Invoke(backgroundWorker1);
              };
            backgroundWorker1.ProgressChanged += (object sender, ProgressChangedEventArgs e) =>
            {
                progressBar1.Value++;
            };
        }

        private void button1_Click(object sender, EventArgs e)
        {
            backgroundWorker1.RunWorkerAsync();
        }
    }
}
